<script type="text/html" template lay-done="layui.data.sendParams(d.params)">
  <div class="layui-form" lay-filter="form_online">
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 120px">是否开启权益</label>
      <div class="layui-input-inline">
          <input type="radio" lay-filter="rights_type" {{d.params.rights_type.value == "none" ? 'checked':''}} name="rights_type" value="none" title="无权益">
          <input type="radio" lay-filter="rights_type" {{d.params.rights_type.value == "key" ? 'checked':''}}  name="rights_type" value="key" title="虚拟权益">
          <input type="radio" lay-filter="rights_type" {{d.params.rights_type.value == "entity" ? 'checked':''}}  name="rights_type" value="entity" title="实物权益">
      </div>
    </div>
    <div class="layui-form-item layui-hide" id="entity">
      <label class="layui-form-label" style="width: 120px">绑定权益</label>
      <div class="layui-input-inline">
        <select name="entity_id">
          <option value="">请选择实物权益</option>
          {{# layui.each(d.params.rightsEntities, function(index, rightsEntity){ }}
          <option value="{{rightsEntity.id}}" {{d.params.entity && d.params.entity.entity_id==rightsEntity.id?'selected':''}}>{{rightsEntity.name}}</option>
          {{# }) }}
        </select>
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-footer">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
          <input type="button" lay-submit lay-filter="submit_resale" value="确认" class="layui-btn">
        </div>
      </div>
    </div>
  </div>
</script>
<script>
  layui.data.sendParams = function (obj) {
    layui.use([], function () {
      let $ = layui.$
        , form = layui.form
        , laydate = layui.laydate

      form.render()

      if (obj.rights_type.value == 'entity') {
        $("#entity").removeClass('layui-hide');
      }

      form.on('radio(rights_type)', function(data){
        if (data.value == 'entity') {
          $("#entity").removeClass('layui-hide');
        } else {
          $("#entity").addClass('layui-hide');
        }
      });
      //日历初始化
      laydate.render({
        elem: '#start_time'
        , type: 'datetime'
      });
      laydate.render({
        elem: '#end_time'
        , type: 'datetime'
      });
    })
  }
</script>
